from xen.xend.XendLogging import log
from xen.xend import scheduler
from xen.xend.server import relocate
-from xen.xend.xenstore import XenNode, DBMap
from xen.xend.xenstore.xstransact import xstransact
# So we stuff the XendDomain instance (self) into xroot's components.
xroot.add_component("xen.xend.XendDomain", self)
self.domains = XendDomainDict()
- self.vmroot = "/domain"
- self.dbmap = DBMap(db=XenNode(self.vmroot))
self.watchReleaseDomain()
self.refresh()
self.dom0_setup()
if notify:
eserver.inject('xend.domain.died', [info.getName(),
info.getDomid()])
- # XXX this should not be needed
- for domdb in self.dbmap.values():
- if not domdb.has_key("xend"):
- continue
- db = domdb.addChild("xend")
- try:
- domid = int(domdb["domid"].getData())
- except:
- domid = None
- if (domid is None) or (domid == id):
- domdb.delete()
def refresh(self):
@param config: configuration
@return: domain
"""
- dominfo = XendDomainInfo.create(self.dbmap.getPath(), config)
+ dominfo = XendDomainInfo.create(config)
self._add_domain(dominfo)
return dominfo
nested = sxp.child_value(config, 'config')
if nested:
config = nested
- return XendDomainInfo.restore(self.dbmap.getPath(), config)
+ return XendDomainInfo.restore(config)
def domain_restore(self, src, progress=False):
"""Restore a domain from file.
MINIMUM_RESTART_TIME = 20
- def create(cls, dompath, config):
+ def create(cls, config):
"""Create a VM from a configuration.
- @param dompath: The path to all domain information
@param config configuration
@raise: VmError for invalid configuration
"""
- log.debug("XendDomainInfo.create(%s, ...)", dompath)
+ log.debug("XendDomainInfo.create(...)")
- vm = cls(getUuid(), dompath, cls.parseConfig(config))
+ vm = cls(getUuid(), cls.parseConfig(config))
vm.construct()
vm.refreshShutdown()
return vm
raise XendError(
'No vm/uuid path in store for existing domain %d' % domid)
- dompath = "/".join(dompath.split("/")[0:-1])
except Exception, exn:
log.warn(str(exn))
- dompath = DOMROOT
uuid = getUuid()
log.info("Recreating domain %d, uuid %s", domid, uuid)
- vm = cls(uuid, dompath, xeninfo, domid, True)
+ vm = cls(uuid, xeninfo, domid, True)
vm.refreshShutdown(xeninfo)
return vm
recreate = classmethod(recreate)
- def restore(cls, dompath, config, uuid = None):
+ def restore(cls, config, uuid = None):
"""Create a domain and a VM object to do a restore.
- @param dompath: The path to all domain information
@param config: domain configuration
@param uuid: uuid to use
"""
- log.debug("XendDomainInfo.restore(%s, %s, %s)", dompath, config, uuid)
+ log.debug("XendDomainInfo.restore(%s, %s)", config, uuid)
if not uuid:
uuid = getUuid()
except TypeError, exn:
raise VmError('Invalid ssidref in config: %s' % exn)
- vm = cls(uuid, dompath, cls.parseConfig(config),
+ vm = cls(uuid, cls.parseConfig(config),
xc.domain_create(ssidref = ssidref))
vm.create_channel()
vm.configure()
parseConfig = classmethod(parseConfig)
- def __init__(self, uuid, parentpath, info, domid = None, augment = False):
+ def __init__(self, uuid, info, domid = None, augment = False):
self.uuid = uuid
self.info = info
- self.path = parentpath + "/" + uuid
+ self.path = DOMROOT + "/" + uuid
if domid:
self.domid = domid